<template>
  <div class="mod-config editViewContainer">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :deleteApiName="deleteApiName"
                :showAttrs="showAttrs"
                :sumInfo='sumInfo'
                :optionWidth="200"
                :importApiName="importApiName"
                :adviceNoteFunc="adviceNoteFunc"
                :reorderFunc="reorderFunc"
    >
      <template v-slot:foot="{scope}">
        <el-tooltip v-if="isAuth(deleteAuthName)" class="item" effect="dark" content="订单变更" placement="bottom" :hide-after="1800" :open-delay="800">
          <el-button type="primary" icon="el-icon-edit" size="small" @click="updateOrderDetail(R.prop('row', scope))"></el-button>
        </el-tooltip>

        <el-tooltip v-if="isAuth(deleteAuthName)" class="item" effect="dark" content="变更发货通知状态" placement="bottom" :hide-after="1800" :open-delay="800">
          <el-button type="danger" size="small" icon="el-icon-truck" @click="deliveryOrderDetail(scope.row)"></el-button>
        </el-tooltip>

        <el-tooltip v-if="isAuth(deleteAuthName)" class="item" effect="dark" content="仅光瓶和拉管瓶可转"
                    placement="bottom" :hide-after="2800" :open-delay="500">
          <el-button type="text" size="small" @click="deepProductOrderDialog(scope.row)" >转深加工</el-button>
        </el-tooltip>

      </template>
    </table-view>

    <productinfo-add-or-update v-if="productInfoVisible" ref="productInfo"></productinfo-add-or-update>
    <client-info-add-or-update v-if="clientInfoVisible" ref="clientInfo"></client-info-add-or-update>
    <productplannotice-add-or-update v-if="productPlanNoticeVisible" ref="productPlanNotice" @refreshDataList="getDataList"></productplannotice-add-or-update>
    <deep-category-add-or-update v-if="deepCategoryInfoVisible" ref="deepCategory" ></deep-category-add-or-update>
    <model-info-add-or-update v-if="modelInfoVisible" ref="modelInfo"></model-info-add-or-update>
    <order-update v-if="orderUpdateVisible" ref="orderInfoUpdate" @refreshDataList="getDataList"></order-update>
    <contract-order-info-add-or-update v-if="contractOrderInfoAddOrUpdateVisible" ref="contractOrderInfo" @refreshDataList="getDataList"></contract-order-info-add-or-update>

    <el-dialog
      title="选择当前订单的状态"
      :visible.sync="dialogVisible"
      width="30%">
      <el-radio-group v-model="status">
        <el-radio :label="-1">预排</el-radio>
        <el-radio :label="0">待配货</el-radio>
        <el-radio :label="1">暂时下线</el-radio>
        <el-radio :label="2">加急</el-radio>
        <el-radio :label="3">正常</el-radio>
        <el-radio :label="4">生产中</el-radio>
        <el-radio :label="5">生产完成</el-radio>
        <el-radio :label="90">客户待确认</el-radio>
        <el-radio :label="99">取消</el-radio>
      </el-radio-group>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="modifyOrderStatus">确 定</el-button>
      </span>
    </el-dialog>

    <el-dialog
      title="选择当前纸箱下单的状态"
      :visible.sync="boxOrderDialogVisible"
      width="30%">
      <el-radio-group v-model="boxOrderStatusRadio">
        <el-radio :label="0">未下单</el-radio>

        <el-radio :label="2">已下单</el-radio>

        <el-radio :label="5">正在加工</el-radio>

        <el-radio :label="10">入库完成</el-radio>

        <el-radio :label="15">改用托盘</el-radio>

        <el-radio :label="20">来料加工</el-radio>
      </el-radio-group>
      <span slot="footer" class="dialog-footer">
        <el-button @click="boxOrderDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="modifyBoxOrderStatus">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="修改损耗数量"
      :visible.sync="orderIssuesNumberVisible"
      width="30%">
      <el-input-number v-model="orderIssuesNumber">
      </el-input-number>
      <span slot="footer" class="dialog-footer">
        <el-button @click="orderIssuesNumberVisible = false">取 消</el-button>
        <el-button type="primary" @click="modifyOrderIssuesNumber">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="组长审批"
      :visible.sync="teamLeadApprovalVisible"
      width="30%">
      <label >审批状态： </label>
      <el-radio-group v-model="teamLeadApproval" >
        <el-radio :label="3" border>组长待审核</el-radio>

        <el-radio :label="4" border>组长驳回</el-radio>

        <el-radio :label="5" border>组长通过</el-radio>

      </el-radio-group>
      <br>
      <br>
      <label >审批意见： </label>
      <el-input v-model="teamLeadOpinion" placeholder="请输入组长审核意见">
      </el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="teamLeadApprovalVisible = false">取 消</el-button>
        <el-button type="primary" @click="modifyTeamLeadApproval">确 定</el-button>
      </span>

    </el-dialog>
    <el-dialog
      title="批量制定发货通知计划"
      :visible.sync="orderPlanNoticeVisible"
      :fullscreen="true"
      :before-close="handleClose"
    >

      <el-form
        ref="dataForm"
        label-width="120px"
        label-position="left"
        style="margin-left:30px"
      >


        <el-form-item label="发货日期" style="width: 400px">
          <el-date-picker
            v-model="deliveryTime"
            align="right"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd HH:mm:ss"
            >
          </el-date-picker>

        </el-form-item>

        <el-form-item label="预计到达时间" style="width: 400px">
          <el-date-picker
            v-model="arriveTime"
            align="right"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>

        </el-form-item>


<!--        <el-form-item-->
<!--          prop="freight"-->
<!--          label="运费"-->
<!--          style="width: 400px"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-input-number controls-position="right" size="small" :min="0"  v-model="freight"  placeholder="运费"></el-input-number>-->
<!--          </template>-->

<!--        </el-form-item >-->

<!--        <el-form-item-->
<!--          prop="totalWeightInfo"-->
<!--          label="重量"-->
<!--          style="width: 400px"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-input-number controls-position="right" size="small" :min="0"  v-model="totalWeightInfo"  placeholder="重量"></el-input-number>-->
<!--          </template>-->

<!--        </el-form-item>-->

        <el-form-item
          prop="remark"
          label="备注"
          style="width: 400px"
        >
          <template slot-scope="scope">
            <el-input type="textarea" controls-position="right" size="small" :min="0"  v-model="remark" placeholder="备注"></el-input>
          </template>
        </el-form-item>

      </el-form>

      <el-table
        :data="tableListData"
        border
        style="display: inline-block">
        <el-table-column
          prop="contractNo"
          label="合同编号"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-input controls-position="right" size="small" readOnly  v-model="scope.row.contractNo" placeholder="合同编号"></el-input>
          </template>
        </el-table-column>
<!--        <el-table-column-->
<!--          prop="orderNo"-->
<!--          label="订单编号"-->
<!--          align="center"-->
<!--          width="170"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-input controls-position="right" size="small" readOnly  v-model="scope.row.orderNo" placeholder="订单编号"></el-input>-->
<!--          </template>-->
<!--        </el-table-column>-->

        <el-table-column
          prop="productNo"
          label="产品名称"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-input controls-position="right" size="small" readOnly  v-model="scope.row.productNo" placeholder="产品名称"></el-input>
          </template>
        </el-table-column>

        <el-table-column
          prop="customerRequire"
          label="规格描述"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-input controls-position="right" size="small" readOnly  v-model="scope.row.customerRequire" placeholder="规格工艺描述"></el-input>
          </template>
        </el-table-column>

<!--        <el-table-column-->
<!--          prop="clientName"-->
<!--          label="客户名称"-->
<!--          align="center"-->
<!--          width="150"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-input controls-position="right" size="small"  v-model="scope.row.clientName" placeholder="客户名称"></el-input>-->
<!--          </template>-->
<!--        </el-table-column>-->

<!--        <el-table-column-->
<!--          prop="productWeight"-->
<!--          label="克重"-->
<!--          width="130"-->
<!--          align="center"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-input-number controls-position="right" size="small" :min="0"  v-model="scope.row.productWeight" placeholder="克重"></el-input-number>-->
<!--          </template>-->
<!--        </el-table-column>-->


        <el-table-column
          prop="orderProductNumber"
          label="订单数量"
          width="150"
          align="center"
        >
          <template slot-scope="scope">
            <el-input-number controls-position="right" size="small" :min="0"  v-model="scope.row.orderProductNumber"  placeholder="数量"></el-input-number>
          </template>
        </el-table-column>

        <el-table-column
          prop="putInStorageNumber"
          label="库存数量"
          width="130"
          align="center"
        >
          <template slot-scope="scope">
            <el-input-number controls-position="right" size="small" :min="0"  v-model="scope.row.putInStorageNumber"  placeholder="库存数量"></el-input-number>
          </template>
        </el-table-column>

          <el-table-column
            prop="leaveStorageNumber"
            label="已发数量"
            width="130"
            align="center"
          >
            <template slot-scope="scope">
              <el-input-number controls-position="right" size="small" :min="0"  v-model="scope.row.leaveStorageNumber"  placeholder="已发数量"></el-input-number>
            </template>
          </el-table-column>

        <el-table-column
          prop="deliveryType"
          label="发货类型"
          align="center"
          width="140"
        >
          <template slot-scope="scope">
            <el-select v-model="scope.row.deliveryType" clearable filterable   placeholder="发货类型">
              <el-option label="按数量"   :value=0>按数量</el-option>
              <el-option label="全发"  :value=1>全发</el-option>
            </el-select>
          </template>
        </el-table-column>

        <el-table-column
          prop="deliveryNumber"
          label="发货数量"
          align="center"
        >
          <template slot-scope="scope">
            <el-input-number size="small" controls-position="right"  v-model="scope.row.deliveryNumber" placeholder="发货数量"></el-input-number>
          </template>
        </el-table-column>

        <el-table-column
          prop="boxPackText"
          label="箱唛描述"
          align="center"
        >
          <template slot-scope="scope">
            <el-input type="textarea" controls-position="right" size="small" :min="0"  v-model="scope.row.boxPackText" placeholder="箱唛描述"></el-input>
          </template>
        </el-table-column>

        <el-table-column
          prop="remark"
          label="备注"
          align="center"
        >
          <template slot-scope="scope">
             <el-input type="textarea" controls-position="right" size="small" :min="0"  v-model="scope.row.remark" placeholder="备注"></el-input>
          </template>
        </el-table-column>

<!--        <el-table-column-->
<!--          prop="deliveryAddress"-->
<!--          label="收货地址"-->
<!--          width="200"-->
<!--          align="center"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-input type="textarea" controls-position="right" size="small" :min="0"  v-model="scope.row.deliveryAddress" placeholder="收货地址"></el-input>-->
<!--          </template>-->
<!--        </el-table-column>-->

      </el-table>


      <span slot="footer" class="dialog-footer">
        <el-button @click="orderPlanNoticeVisible = false">取 消</el-button>
        <el-button type="primary" @click="saveConsignNoteInfo">确 定</el-button>
      </span>

    </el-dialog>

    <el-dialog
      title="光瓶和拉管瓶转深加工"
      :visible.sync="orderTimeLineVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="true"
      width="50%">
      <div class="block">
        <template v-for="(item, index) in productDeepCategoryList">
          <div :key="index" style="display: flex;position: relative; margin-top: 5px; width: 97%">
            <el-select v-model="item['deepCategoryIdList']" filterable clearable multiple
                       style="margin-right: 5px;" placeholder="请选择深加工工艺">
              <el-option v-for="item in deepCategoryList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>

            <el-input v-model="item['customerRequire']" placeholder="工艺描述"

                      style="margin-right: 5px;"></el-input>

            <el-input-number v-model="item['purchaseNumber']" placeholder="采购数量"
                             type="number"
                             style="margin-right: 5px;"></el-input-number>

            <el-tooltip class="item" effect="dark" content="新增"
                        placement="bottom">
              <a class="el-icon-circle-plus-outline" @click="addOneLine(index+1)"
                 style="position: absolute;right: -17px; top: 10px;"></a>
            </el-tooltip>
            <el-tooltip v-if="productDeepCategoryList.length > 1" class="item" effect="dark" content="删除" placement="bottom">
              <a class="el-icon-remove-outline" @click="deleteOneLine(index)"
                 style="position: absolute;right: -35px; top: 10px;"></a>
            </el-tooltip>
          </div>
        </template>
        <div class="ScreenShot" >
          <label >深加工样图</label>
          <div v-show="!show" class="pasteInputDiv" @paste="handlePaste">
            <input type="text" class="pasteInput" autosize
                   placeholder="请粘贴深加工图片" maxlength="0">
          </div>
          <div v-if="show" class="pasteImgDiv">
            <i class="el-icon-error close-position"  @click="deleteImg" />
            <el-image
              class="pasteImg"
              :src="url"
              fit="fill"
              :z-index="99999"
            >
            </el-image>
          </div>
        </div>
      </div>


      <span slot="footer" class="dialog-footer">
        <el-button @click="orderTimeLineVisible = false">取 消</el-button>
        <el-button type="primary" @click="updateContractOrderByDeep">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import AddOrUpdate from './orderdetail-add-or-update'
import OrderUpdate from './orderdetail-update'
import ContractOrderInfoAddOrUpdate from '@/views/modules/contract/contractorderinfo-add-or-update'

import tableView from '@/components/tableView/index'
import basicMixins from '@/utils/commonViewMixins'
import ProductinfoAddOrUpdate from '@/views/modules/product/productinfo-add-or-update'
import ProductplannoticeAddOrUpdate from '@/views/modules/product/productplannotice-add-or-update'
import ClientInfoAddOrUpdate from '@/views/modules/client/clientinfo-add-or-update'
import DeepCategoryAddOrUpdate from '@/views/modules/deep/deepcategory-add-or-update'
import {mRequest} from '@/utils/request'
import {exportHandle, isAuth} from '@/utils'
import ModelInfoAddOrUpdate from '@/views/modules/model/modelinfo-add-or-update'
import treeView from '@/components/treeView'
import {API_DEFAULT_CONFIG} from '@/config'

export default {
  mixins: [basicMixins],
  data() {
    return {
      isAuth: isAuth,
      status: 0,
      bigMouth: '',
      show: false,
      deepProductImage: '',
      contractOrderId: '',
      clientId: '',
      productId: '',
      productNo: '',
      deepCategoryList: [],
      url: '',
      urlAttr: [],
      file: null,
      boxOrderStatusRadio: 0,
      orderIssuesNumber: 0,
      dialogVisible: false,
      modelInfoVisible: false,
      orderIssuesNumberVisible: false,
      boxOrderDialogVisible: false,
      productPlanNoticeVisible: false,
      contractOrderInfoAddOrUpdateVisible: false,
      productInfoVisible: false,
      clientInfoVisible: false,
      deepCategoryInfoVisible: false,
      teamLeadApprovalVisible: false,
      orderPlanNoticeVisible: false,
      orderUpdateVisible: false,
      orderTimeLineVisible: false,
      updatePlanOrderStatus: false,
      productDeviceList: [],
      deviceIdList: [],
      orderDetailList: [],
      productInfoList: [],
      modelInfoList: [],
      tableListData: [],
      productDeviceTreeList: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      sysUserList: [],
      deviceId: '',
      onlineTime: '',
      teamLeadApproval:6,
      teamLeadOpinion: '通过',
      sumInfo: {orderProductNumber: 'orderProductNumber',totalPrice:'totalPrice'},
      deliveryTime: '',
      arriveTime: '',
      licencePlateId: '',
      licencePlateList: [],
      taxInclusive: 0,
      freight: '',
      totalWeightInfo: '',
      remark: '',
      searchAttrs: {
        clientContractNo: {
          placeholder: '请输入合同编号'
        },
        productNo: {
          label: '产品名称',
          placeholder: '请输入产品名称',
        },
        status: {
          label: '订单状态',
          placeholder: '请输入订单状态'
        },
        clientId: {
          label: '客户名称',
          clearable: true,
          type: 'autoComplete',
          placeholder: '请输入客户名称',
          querySearchApiName: 'clientApi/getClientList'
        },
        dateTimeRange: {
          type: 'date',
          dateType: 'daterange',
          clearable: true
        }
      },
      primaryKey: 'id',
      listApiName: 'orderApi/listOrderDetailByContract',
      deleteApiName: 'orderApi/deleteOrderDetail',
      importApiName: 'orderApi/importOrderDetail',
      exportApiName: 'orderApi/exportOrderDetailInfo',
      deleteAuthName: 'order:orderdetail:delete',
      boxOrderAuthName: 'order:orderdetail:boxOrder',
      teamLeadApprovalAuthName: 'order:orderdetail:teamLeadApproval',
      showAttrs: {
        contractNo: {
          label: '合同编号',
          width: 150,
          type: 'labelWithStatus',
          statusAttr: 'messageStatus',
          items: [
            {value: 0, text: '未读', tagType: 'danger'}
          ]
        },

        /**
         *   {label: 0, text: '待配货'},
         *             {label: 5, text: '未出货'},
         *             {label: 10, text: '已出'},
         *             {label: 15, text: '缺货'},
         */
        clientName: {label: '客户', width: 120, showAuthName: 'order:unitprice:show'},
        needPurchaseType:{
          label: '订单模式',
          width: 110,
          type: 'radio',
          items: [
            {value: 0, text: '通货', tagType: 'success'},
            {value: 1, text: '现模'},
            {value: 2, text: '开模',tagType:'danger'}
          ]
        },

        // purchaseStatus:{
        //   label: '采购状态',
        //   width: 110,
        //   type: 'radio',
        //   items: [
        //     {value: -5, text: '采购退回', tagType: 'danger'},
        //     {value: 0, text: '待采购', tagType: 'info'},
        //     {value: 2, text: '采购进行中'},
        //     {value: 3, text: '采购逾期预警',tagType:'warning'},
        //     {value: 4, text: '采购已逾期', tagType: 'danger'},
        //     {value: 6, text: '采购暂停', tagType: 'info'},
        //     {value: 7, text: '入库进行中',tagType: 'warning'},
        //     {value: 8, text: '入库完成',tagType: 'success'},
        //     {value: 15, text: '入库完成-其它库',tagType: 'success'},
        //     {value: 17, text: '挑选', tagType: 'warning'},
        //     {value: 18, text: '合格', tagType: 'success'},
        //     {value: 19, text: '不合格', tagType: 'danger'},
        //     {value: 20, text: '特采', tagType: 'warning'},
        //     {value: 50, text: '部分出库中', tagType: 'warning'},
        //     {value: 55, text: '全部出库完成', tagType: 'success'},
        //     {value: 99, text: '采购取消', tagType: 'danger'},
        //   ]
        // },
        status: {
          label: '订单状态',
          type: 'radio',
          width: 100,
          items: [
            {value: 5, text: '待询价',tagType: 'info'},
            {value: 7, text: '询价中', tagType: 'warning'},
            {value: 10, text: '询价完成', },
            {value: 20, text: '供应商已确认', tagType: 'success'},
            {value: 23, text: '试样模开模中', tagType: 'warning'},
            {value: 26, text: '试样模转打样', tagType: 'success'},
            {value: 30, text: '单打样中', tagType: 'warning'},
            {value: 33, text: '打样客户待确认', tagType: 'info'},
            {value: 38, text: '打样客户通过', tagType: 'success'},
            {value: 41, text: '生产模开模具中', tagType: 'warning'},
            {value: 45, text: '生产模完成', tagType: 'success'},
            {value: 50, text: '大货生产中', tagType: 'warning'},
            {value: 53, text: '大货等待客户确认', tagType: 'info'},
            {value: 58, text: '大货客户通过', tagType: 'success'},
            {value: 60, text: '大货生产完成'},
            {value: 63, text: '入库中', tagType: 'warning'},
            {value: 65, text: '入库完成', tagType: 'success'},
            {value: 69, text: '等待质检', tagType: 'info'},
            {value: 75, text: '质检完成', },
            {value: 88, text: '尾款已收', tagType: 'success'},
            {value: 90, text: '开发货通知单'},
            {value: 93, text: '出库中',tagType: 'warning'},
            {value: 95, text: '出库完成',tagType: 'success'},
            {value: 99, text: '订单取消', tagType: 'danger'}
          ]
        },
        orderTime: {label: '订单时间', type: 'date', width: 100},
        productNo: {
          label: '产品编号',
          width: 150,
          type: 'linkLabel',
          routerName: 'product-product-info-all',
          searchKey: 'productNo'
        },
        // lightGlassPrice: {
        //   label: '光瓶价格',
        //   showAuthName: 'order:unitprice:show'
        // },
        sampleImage:{
          label: '样品图片',
          type: 'image',
          width: 95
        },
        unitPrice: {
          label: '单价',
          showAuthName: 'order:unitprice:show'
        },
        orderProductNumber: {label: '订单数量'},
        totalPrice: {
          label: '总价',
          showAuthName: 'order:unitprice:show'
        },
        customerRequire:{
          label: '规格描述',
          width: 150
        },
        // deepProductImage
        purchaseType: {
          label: '采购类型',
          type: 'radio',
          width: 110,
          items: [
            {value: 1, text: '光瓶',tagType:'success'},
            {value: 23, text: '纸箱',tagType: 'danger'},
            {value: 25, text: '礼盒',tagType: 'danger'},
            {value: 3, text: '喷头',tagType: 'success'},
            {value: 4, text: '中套'},
            {value: 5, text: '披肩',tagType: 'warning'},
            {value: 6, text: '塑料盖',tagType:'warning'},
            {value: 7, text: '锌合金盖',tagType:'danger'},
            {value: 8, text: '香薰棒',tagType:'danger'},
            {value: 9, text: '树脂盖',tagType:'success'},
            {value: 11, text: '深加工',tagType:'danger'},
            {value: 66, text: '滚珠',tagType:'info'},
            {value: 77, text: '电化铝盖',tagType:'warning'},
            {value: 88, text: '软管类',tagType:'info'},
            {value: 99, text: '其它',tagType:'danger'},
            {value: 100, text: '配件'},
            {value: 111, text: '拉管玻璃瓶'},
            {value: 999, text: '标牌',tagType:'info'},
            {value: 666, text: '木头竹子盖'},
            {value: 888, text: '膏霜罐'},
            {value: 8888, text: '小喷雾乳液泵',tagType:'success'},
            {value: 88888, text: '香水樽',tagType:'warning'},
            {value: 888888, text: '塑料瓶'},
          ]
        },
        qualityGrade:{
          label: '质量等级',
          type: 'radio',
          items: [
            {value: 'A', text: 'A',tagType:'success'},
            {value: 'B', text: 'B'},
            {value: 'C', text: 'C',tagType:'warning'}
          ]
        },
        putInStorageNumber:{
          label: '入库数量',
          width: 95
        },
        leaveStorageNumber:{
          label: '出库数量',
          width: 95
        },
        productImageId: {label: '图片', type: 'image'},

        // deepProductImage:{
        //   label: '光瓶深加工样图',
        //   type: 'image',
        //   width: 95
        // },
        relateDeepProductImage:{
          label: '配件样图',
          type: 'image',
          width: 95
        },
        groupType: {
          label: '组合'
        },
        productWeight: {label: '克数'},
        productVolume: {label: '容量'},
        boxPackText:{
          label: '箱唛描述'
        },
        remark: {label: '备注', width: 140},

        // bottleCraft: {label: '工艺'},
        salesperson: {label: '销售'},
        orderNo: {
          label: '订单子编号',
          width: 150
        },

      },
      activities: [{
        content: '客户确认订单信息',
        timestamp: '2018-04-12 20:46',
        size: 'large',
        type: 'primary',
        icon: 'el-icon-more'
      },
        {
        content: '组长审核完成',
        timestamp: '2018-04-03 20:46',
        color: '#0bbd87'
      }, {
        content: '纸箱审核完成',
        timestamp: '2018-04-03 20:46',
        size: 'large'
      },
        {
          content: '模具审核完成',
          timestamp: '2018-04-03 20:46',
          size: 'large'
        },
        {
        content: '排单待审核',
        timestamp: '2018-04-03 20:46'
      },
      {
        content: '纸箱生产中',
        timestamp: '2018-04-03 20:46',
        size: 'large'
      },
        {
          content: '纸箱入库中',
          timestamp: '2018-04-03 20:46',
          size: 'large'
        },
        {
          content: '预计上机时间',
          timestamp: '2018-04-03 20:46'
        },
        {
          content: '生产中',
          timestamp: '2018-04-03 20:46'
        },
        {
          content: '成品入库',
          timestamp: '2018-04-03 20:46'
        },
        {
          content: '生成发货通知单',
          timestamp: '2018-04-03 20:46'
        },
        {
          content: '出库中',
          timestamp: '2018-04-03 20:46',
          type: 'success'
        },
        {
          content: '出库完成',
          timestamp: '2018-04-03 20:46',
          color: '#0bbd87'
        }

      ],
      productDeepCategoryList:[{deepCategoryIdList:[],customerRequire:'', purchaseNumber: 0}],

    }
  },
  watch:{
    url() {
      if (this.url === '') {
        this.show = false
        this.urlAttr = []
      } else {
        this.show = true
      }
    },
    attrUrl: {
      handler() {
        if (this.R.isNil(this.attrUrl) || this.R.equals('', this.attrUrl.trim())) {
          this.url = null
        } else {
          this.url = `${API_DEFAULT_CONFIG.baseURL}/pub/${this.attrUrl}?token=${this.token}`
        }
      },
      deep: true
    }
  },
  computed: {
    /**
     * @return {string}
     */
    URL() {
      return `${this.imageUrl}${this.urlAttr}?token=${this.token}`
    },
    token() {
      return this.$cookie.get('token')
    },
    imageUrl() {
      return `${API_DEFAULT_CONFIG.baseURL}/pub`
    },
    srcList() {
      return [`${this.imageUrl}${this.urlAttr}?token=${this.token}`]
    }
  },
  mounted() {
    this.initDeepCategoryList()
  },
  methods: {
    deepProductOrderDialog(order) {
      console.log(order)
      this.productDeepCategoryList = [{deepCategoryIdList: [], customerRequire: '', purchaseNumber: 0}]
      this.deepProductImage = ''
      this.orderTimeLineVisible = true

      this.contractOrderId = order.contractOrderId
      this.clientId = order.clientId
      this.productId = order.productId
      this.productNo = order.productNo
    },


    deliveryOrderDetail(order) {
      this.modifyOrder = order
      if (this.modifyOrder.shippingStatus == 1) {
        this.modifyOrder.shippingStatus = 0
      }else {
        this.modifyOrder.shippingStatus = 1
      }
      mRequest('orderApi/updateOrderDetail', this.modifyOrder, () => {
        this.modifyOrder = null
        this.getDataList()
      })
    },
    productDeviceTreeListInit() {
      mRequest('productApi/getProductDeviceListByParent', {}, (res) => {
        this.productDeviceList = this.R.pathOr([], ['data', 'list'], res)
        const productDeviceTreeList = [{
          id: '',
          name: '生产线信息',
          nodeType: 0,
          children: []
        }]

        productDeviceTreeList[0].children = this.productDeviceList
        this.productDeviceTreeList = productDeviceTreeList;
      })
    },
    openOrderStatusDialog(order) {
      this.dialogVisible = true
      this.modifyOrder = order
      const {status} = order

      this.status = status
    },
    modifyOrderStatus() {
      if (this.modifyOrder.status === this.status) {
        return
      }
      this.modifyOrder.status = this.status

      mRequest('orderApi/updateOrderDetail', this.modifyOrder, () => {
        this.modifyOrder = null
        this.status = 0
        this.dialogVisible = false
        this.getDataList()
      })
    },
    modifyTeamLeadApproval() {
      if (this.modifyOrder.teamLeadApproval === this.teamLeadApproval) {
        return
      }
      this.modifyOrder.teamLeadApproval = this.teamLeadApproval
      this.modifyOrder.teamLeadOpinion = this.teamLeadOpinion

      mRequest('orderApi/updateOrderDetail', this.modifyOrder, () => {
        this.modifyOrder = null
        this.teamLeadApproval = 6
        this.teamLeadOpinion = ''
        this.teamLeadApprovalVisible = false
        this.getDataList()
      })
    },
    openTeamLeadApprovalDialog(order) {
      this.teamLeadApprovalVisible = true
      this.modifyOrder = order
      const {teamLeadApproval} = order

      this.teamLeadApproval = teamLeadApproval
    },

    openBoxOrderStatusDialog(order) {
      this.boxOrderDialogVisible = true
      this.modifyOrder = order
      const {boxOrderStatus} = order

      this.boxOrderStatusRadio = boxOrderStatus
    },
    modifyBoxOrderStatus(){
      if (this.modifyOrder.boxOrderStatus === this.boxOrderStatusRadio) {
        return
      }
      this.modifyOrder.boxOrderStatus = this.boxOrderStatusRadio

      mRequest('orderApi/updateOrderDetail', this.modifyOrder, () => {
        this.modifyOrder = null
        this.boxOrderStatusRadio = 0
        this.boxOrderDialogVisible = false
        this.getDataList()
      })
    },
    modifyOrderIssuesNumber() {
      if (this.modifyOrder.orderIssuesNumber === this.orderIssuesNumber) {
        return
      }
      this.modifyOrder.orderIssuesNumber = this.orderIssuesNumber

      mRequest('orderApi/updateOrderDetail', this.modifyOrder, () => {
        this.modifyOrder = null
        this.orderIssuesNumber = 0
        this.orderIssuesNumberVisible = false
        this.getDataList()
      })
    },
    openProductPlanNotice(id) {
      this.productPlanNoticeVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.productPlanNotice)) {
          this.$refs.productPlanNotice.init(null, {orderDetailId: id}, () => {
            this.$router.push({name: 'product-productplannotice'})
          })
        }
      })
    },
    openProductInfoDialog(cb) {
      this.productInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.productInfo)) {
          this.$refs.productInfo.init(null, {status: 1}, cb)
        }
      })
    },
    openClientInfoDialog(cb) {
      this.clientInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.clientInfo)) {
          this.$refs.clientInfo.init(null, {status: 1}, cb)
        }
      })
    },
    openDeepCategoryInfoDialog(cb){
      this.deepCategoryInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.deepCategory)) {
          this.$refs.deepCategory.init(null, {status: 1}, cb)
        }
      })
    },
    openOrderIssuesNumberDialog(order){
      this.orderIssuesNumberVisible = true
      this.modifyOrder = order
      const {orderIssuesNumber} = order

      this.orderIssuesNumber = orderIssuesNumber
    },
    openOrderTimeLineDialog(order) {
      this.orderTimeLineVisible = true
      mRequest('orderApi/getOrderTimeLineInfoByOrderDetailId',{orderDetailId: order.id},(res)=>{
        this.activities = this.R.pathOr([], ['data', 'list'], res)

      })
    },
    initSysUserInfoList() {
      mRequest('systemApi/listAllUser', {}, (res) => {
        this.sysUserList = this.R.pathOr([], ['data', 'list'], res)
      })
    },

    initProductDeviceListByParent() {
      mRequest('productApi/getProductDeviceListByParent', {}, (res) => {
        this.productDeviceList = this.R.pathOr([], ['data', 'list'], res)
      })
    },
    initOrderDetailList() {
      mRequest('orderApi/getOrderDetailList', {}, (res) => {
        this.orderDetailList = this.R.pathOr([], ['data', 'list'], res)
      })
    },
    initProductInfoList() {
      mRequest('productApi/getProductInfoList', {}, (res) => {
        this.productInfoList = this.R.pathOr([], ['data', 'list'], res)
      })
    },
    initDeepCategoryList(attrName = '') {
      mRequest('deepApi/deepCategoryList', {}, (res) => {
        this.deepCategoryList = this.R.pathOr([], ['data', 'list'], res)
      })
    },
    initModelInfoList(attrName = 'modelInfoId') {
      mRequest('modelApi/getModelInfoList', {}, (res) => {
        this.modelInfoList = this.R.pathOr([], ['data', 'list'], res)
      })
    },
    initLicencePlateInfoList() {
      mRequest('licenceApi/getLicencePlateInfoList', {}, (res) => {
        this.licencePlateList = this.R.pathOr([], ['data', 'list'], res)
      })
    },
    updateOrderDetail(param){
      this.orderUpdateVisible = true

      this.$nextTick(() => {

        if (!this.R.isNil(this.$refs.orderInfoUpdate)) {
          this.$refs.orderInfoUpdate.init(param.id, param,null)
        }
      })
    },
    reorderFunc(rows) {
      console.log(rows)
      this.contractOrderInfoAddOrUpdateVisible=true

      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.contractOrderInfo)) {
          this.$refs.contractOrderInfo.init(null, {tableListData: rows})
        }
      })
    },
    openOrderDialog(param, cb) {
      this.orderUpdateVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.orderInfoUpdate)) {
          this.$refs.orderInfoUpdate.init(param.id, param, cb, false)
        }
      })
    },
    adviceNoteFunc(rows) {
      this.onlineTime = ''
      this.tableListData = []

      for (let i = 0; i < rows.length; i++) {
        let _obj = {
          'orderDetailId': this.R.prop('id', rows[i]),
          'contractNo': this.R.prop('contractNo', rows[i]),
          'deliveryType': 0,
          'deliveryNumber': 0,
          orderNo: this.R.prop('orderNo', rows[i]),
          productNo: this.R.prop('productNo', rows[i]),
          clientName: this.R.prop('clientName', rows[i]),
          productWeight: this.R.prop('productWeight', rows[i]),
          unitPrice: this.R.prop('lightGlassPrice', rows[i]),
          orderProductNumber: this.R.prop('orderProductNumber', rows[i]),
          putInStorageNumber: this.R.prop('putInStorageNumber', rows[i]),
          leaveStorageNumber: this.R.prop('leaveStorageNumber', rows[i]),
          weightInfo: this.R.prop('weightInfo', rows[i]),
          deliveryAddress: this.R.prop('deliveryAddress', rows[i]),
          contractOrderId: this.R.prop('contractOrderId', rows[i]),
          productId: this.R.prop('productId', rows[i]),
          clientId: this.R.prop('clientId', rows[i]),
          customerRequire: this.R.prop('customerRequire', rows[i])
        }
        this.tableListData.push(_obj)

      }
      this.orderPlanNoticeVisible = true

    },
    saveConsignNoteInfo() {

      mRequest("consignApi/saveConsignNoteAndDetailList", {
        'deliveryTime': this.deliveryTime,
        'arriveTime': this.arriveTime,
        'licencePlateId': this.licencePlateId,
        'taxInclusive': this.taxInclusive,
        'freight': this.freight,
        'totalWeightInfo': this.totalWeightInfo,
        'remark': this.remark,
        'onlineTime': this.onlineTime,
        'deviceId': this.deviceId,
        'tableListData': this.tableListData
      }, (res => {
        let data = res.data
        if (data && data.code == 0) {

          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.orderPlanNoticeVisible = false
              this.getDataList()
              this.$emit('refreshDataList')
            }
          })
        } else {
          this.$message.error(data.msg)
        }
      }))
    },
    updateContractOrderByDeep() {
      mRequest("contractApi/updateContractOrderByDeep", {
        'deepProductImage': this.deepProductImage,
        'contractOrderId': this.contractOrderId,
        'clientId': this.clientId,
        'productId': this.productId,
        'productNo': this.productNo,
        'productDeepCategoryList': this.productDeepCategoryList
      }, (res => {
        let data = res.data
        if (data && data.code == 0) {

          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.orderTimeLineVisible = false
              this.getDataList()
              this.$emit('refreshDataList')
            }
          })
        } else {
          this.$message.error(data.msg)
        }
      }))
    },
    addOneLine(index) {
      const item = {deepCategoryIdList:[],customerRequire:'', purchaseNumber: 0}

      this.productDeepCategoryList.splice(index, 0, item)
    },
    deleteOneLine(index) {
      this.productDeepCategoryList.splice(index, 1)
    },
    handlePaste(event) {
      const items = (event.clipboardData || event.originalEvent.clipboardData).items;
      let file = null
      if (!items || items.length === 0) {
        this.$message.error('当前浏览器不支持本地')
        return
      }
      // 搜索剪切板items
      for (let i = 0; i < items.length; i++) {
        if (items[i].type.indexOf('image') !== -1) {
          file = items[i].getAsFile()
          break
        }
      }
      if (!file) {
        this.$message.error('粘贴内容非图片')
        return
      }
      // 此时file就是我们的剪切板中的图片对象
      const reader = new FileReader()
      reader.onload = (event) => {
        this.show = true
        this.uploadImageBase( event.target.result)
      }
      reader.readAsDataURL(file)
      this.$emit('imgFile', file)
      this.file = file
    },
    deleteImg() {
      this.url = ''
      this.show = false
      this.$emit('imgFile', '')
      this.$emit('imgBase64', '')
    },
    uploadImageBase(value) {
      mRequest('systemApi/uploadImageBase', {'imageBase': value}, (res) => {
        this.urlAttr = this.R.pathOr([], ['data', 'imageUrl'], res)
        this.url= `${this.imageUrl}${this.urlAttr}?token=${this.token}`
        this.deepProductImage = this.urlAttr
      })
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    }
  },
  components: {
    ProductplannoticeAddOrUpdate,
    ProductinfoAddOrUpdate,
    ModelInfoAddOrUpdate,
    ClientInfoAddOrUpdate,
    DeepCategoryAddOrUpdate,
    ContractOrderInfoAddOrUpdate,
    OrderUpdate,
    treeView,
    tableView
  }
}
</script>
<style scoped>
.ScreenShot{
  margin-top: 10px;}
.pasteInputDiv{
  box-sizing: border-box;
  width: 158px;
  height: 158px;

}
.pasteInput{
  background-color: #fbfdff;
  border: 1px dashed #c0ccda;
  border-radius: 6px;
  height: 158px;
  line-height: 156px;
  vertical-align: top;
  width: 158px;
  font-size: 19px;
}
.pasteInput:hover{
  cursor: pointer;
  border: 1px dashed #409EFF;
}
.pasteImgDiv{
  position: relative;
  width: 158px;
  height: 158px;
}
.pasteImg{
  position: relative;
  width: 158px;
  height: 158px;
  border: 1px solid #c0ccda ;
  border-radius: 5px;
}
.close-position{
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 22px;
  background: #fff;
  border-radius: 50%;
  color: red;
  font-weight: bold;
  z-index: 9999;
}
.close-position:hover{
  cursor: pointer;
}
</style>
